|
| .NET Framework Class Library |
| ParallelEnumerable..::.WithCancellation<(Of <(TSource>)>) Method |
| ParallelEnumerable Class See Also Send Feedback |
Sets the CancellationToken to associate with the query.
Namespace:
System.Linq
Assembly:
System.Threading (in System.Threading.dll)
Syntax
| Visual Basic (Declaration) |
|---|
Public Shared Function WithCancellation(Of TSource) ( _ source As ParallelQuery(Of TSource), _ cancellationToken As CancellationToken _ ) As ParallelQuery(Of TSource) |
| C# |
|---|
public static ParallelQuery<TSource> WithCancellation<TSource>( ParallelQuery<TSource> source, CancellationToken cancellationToken ) |
Parameters
- source
- Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
A ParallelQuery on which to set the option.
- cancellationToken
- Type: System.Threading..::.CancellationToken
A cancellation token.
Type Parameters
- TSource
- The type of elements of source.
Return Value
ParallelQuery representing the same query as source, but with the registered.
Exceptions
| Exception | Condition |
|---|---|
| System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic). |
| System..::.InvalidOperationException | WithCancellation is used multiple times in the query. |
| System..::.ObjectDisposedException | The CancellationTokenSource associated with the cancellationToken has been disposed. |